// import CryptoJS from 'crypto-js';
import CryptoJS from "crypto-js";
// DES解密
export const decryptByDES = (message,key) => {
  let keyHex = CryptoJS.enc.Base64.parse(key)
  let decrypted = CryptoJS.DES.decrypt({
    ciphertext: CryptoJS.enc.Base64.parse(message.toString())
  }, keyHex, {
    mode: CryptoJS.mode.ECB,
    padding: CryptoJS.pad.Pkcs7
  });
  return decrypted.toString(CryptoJS.enc.Utf8)
}
// DES加密
export const encryptByDES = (message,key) => {
  let keyHex = CryptoJS.enc.Base64.parse(key);

  let encrypted = CryptoJS.DES.encrypt(message, keyHex, {
    mode: CryptoJS.mode.ECB,
    padding: CryptoJS.pad.Pkcs7

  });
  return encrypted.toString();
}